package com.lanou.web.controller;

import com.lanou.entity.OrderData;
import com.lanou.entity.TbOrderShipping;
import com.lanou.service.OrderService;
import com.lanou.utils.ShiHuiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping("/order/pre")
    public Map<String,Object> preCreateOrder(Long userId){
        OrderData order = orderService.createOrder(userId);

        return ShiHuiResult.ok(order);
    }

    @RequestMapping("/order/location")//查询所有收货地址
    public List<TbOrderShipping> orderLocation(String id){
        return  orderService.findLocation(id);
    }
}
